home *** CD-ROM | disk | FTP | other *** search
/ Chip 2006 June / CHIP 2006-06.2.iso / program / freeware / Democracy-0.8.2.exe / xulrunner / python / threadpriority.py < prev    next >
Encoding:
Python Source  |  2006-04-10  |  760 b   |  22 lines

  1. from win32con import *
  2. from ctypes import *
  3. from ctypes.wintypes import *
  4. kernel32 = windll.kernel32
  5. GetCurrentThread = kernel32.GetCurrentThread
  6. SetThreadPriority = kernel32.SetThreadPriority
  7.  
  8. def setNormalPriority():
  9.     SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_NORMAL)
  10.  
  11. def setBackgroundPriority():
  12.     # or possibly THREAD_PRIORITY_LOWEST, which is a bit higher
  13.     SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_IDLE)
  14.  
  15. def setHighPriority():
  16.     SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL)
  17.  
  18. def setMaximumPriority():
  19.     # tempting to go to THREAD_PRIORITY_TIME_CRITICAL here, but that
  20.     # could easily cause problems for other applications.
  21.     SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_HIGHEST)
  22.